﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CrawlerTBDemo
{
    public partial class Content : Form
    {

        private JArray data;

        public Content(JArray data)
        {
            this.data = data;
            InitializeComponent();

            // 设置 ListView 的视图模式为详细信息模式
            listView1.View = View.Details;
            // 添加列头
            listView1.Columns.Add("序号", 60);
            listView1.Columns.Add("名称", 240);
            listView1.Columns.Add("价格", 80);
            listView1.Columns.Add("地区", 80);
            listView1.Columns.Add("店名", 120);
            listView1.Columns.Add("付款人数", 120);
        }

        private void Content_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < data.Count; i++)
            {
                // 获取JSON对象的属性
                string name = (string)data[i]["name"];
                string price = (string)data[i]["price"];
                string area = (string)data[i]["area"];
                string storeName = (string)data[i]["storeName"];
                string payNum = (string)data[i]["payNum"];

                ListViewItem item = new ListViewItem(i + "");
                item.SubItems.Add(name);
                item.SubItems.Add(price);
                item.SubItems.Add(area);
                item.SubItems.Add(storeName);
                item.SubItems.Add(payNum);
                listView1.Items.Add(item);
            }
        }
    }
}
